package com.DreamTeam.daoProxy;

import java.util.List;

import com.DreamTeam.dao.IProductDao;
import com.DreamTeam.daoImpl.ProductDao;
import com.DreamTeam.dbc.MySqlConnection;
import com.DreamTeam.po.Employee;
import com.DreamTeam.po.Product;

public class ProductDaoProxy implements IProductDao {

	private MySqlConnection conn;
	private IProductDao productDao;
	public ProductDaoProxy(){
		conn = new MySqlConnection();
		productDao = new ProductDao(conn.getConnection());
	}
	
	@Override
	public boolean doAdd(Product product) {
		boolean flag = false;
		flag = productDao.doAdd(product);
		conn.closeConnection();
		return flag;
	}

	@Override
	public boolean doUpdate(Product product) {
		// TODO Auto-generated method stub
		boolean flag = false;
		flag = productDao.doUpdate(product);
		conn.closeConnection();
		return flag;
	}

	@Override
	public boolean doDelete(Product product) {
		// TODO Auto-generated method stub
		boolean flag = false;
		flag = productDao.doDelete(product);
		conn.closeConnection();
		return flag;
	}

	@Override
	public List<Product> queryProductAll() {
		// TODO Auto-generated method stub
		List<Product> list;
		list = productDao.queryProductAll();
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Product> queryProduceByColumn(String keyword,String columnName,String orderColumn,String model) {
		// TODO Auto-generated method stub
		List<Product> list;
		list = productDao.queryProduceByColumn(keyword, columnName, orderColumn, model);
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Product> queryOrderByColumnName(String columnName,String model) {
		// TODO Auto-generated method stub
		List<Product> list;
		list = productDao.queryOrderByColumnName(columnName,model);
		conn.closeConnection();
		return list;
	}

	@Override
	public List<Product> queryByKeyword(String keyword) {
		List<Product> list;
		list = productDao.queryByKeyword(keyword);
		conn.closeConnection();
		return list;
	}
	
	

}
